package com.zhou.JavaAndroidFirm.model;

import com.zhou.JavaAndroidFirm.bean.CommentItem;
import com.zhou.JavaAndroidFirm.bean.CommonResponse;
import com.zhou.JavaAndroidFirm.constract.CircleZoneContract;
import com.zhou.JavaAndroidFirm.rx.RxSchedulers;
import com.zhou.JavaAndroidFirm.utils.AppCache;
import com.zhou.JavaAndroidFirm.utils.DatasUtil;

import org.json.JSONException;

import rx.Observable;
import rx.Subscriber;

/**
 * @author Administrator
 * @date 2018/7/20 0020
 * @des
 */
public class CircleZoneModel implements CircleZoneContract.Model {
    @Override
    public Observable<String> getZoneNotReadMsg() {
        return Observable.create(new Observable.OnSubscribe<String>() {
            @Override
            public void call(Subscriber<? super String> subscriber) {
                subscriber.onNext(AppCache.getInstance().getIcon());
                subscriber.onCompleted();
            }
        }).compose(RxSchedulers.<String>io_main());
    }

    @Override
    public Observable<CommonResponse> getListDatas(String type, String uid, int page, int rows) {
        return Observable.create(new Observable.OnSubscribe<CommonResponse>() {
            @Override
            public void call(Subscriber<? super CommonResponse> subscriber) {
                CommonResponse response = null;
                try {
                    response = DatasUtil.getZoneListDatas();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                subscriber.onNext(response);
                subscriber.onCompleted();
            }
        }).compose(RxSchedulers.<CommonResponse>io_main());
    }

    @Override
    public Observable<CommonResponse> deleteCircle(String circleId, int position) {
        return Observable.create(new Observable.OnSubscribe<CommonResponse>() {
            @Override
            public void call(Subscriber<? super CommonResponse> subscriber) {
                subscriber.onNext(new CommonResponse());
                subscriber.onCompleted();
            }
        }).compose(RxSchedulers.<CommonResponse>io_main());
    }

    @Override
    public Observable<CommonResponse> addFavort(String publishId, String publishUserId) {
        return Observable.create(new Observable.OnSubscribe<CommonResponse>() {
            @Override
            public void call(Subscriber<? super CommonResponse> subscriber) {
                subscriber.onNext(new CommonResponse());
                subscriber.onCompleted();
            }
        }).compose(RxSchedulers.<CommonResponse>io_main());
    }

    @Override
    public Observable<CommonResponse> deleteFavort(String publishId, String publishUserId) {
        return Observable.create(new Observable.OnSubscribe<CommonResponse>() {
            @Override
            public void call(Subscriber<? super CommonResponse> subscriber) {
                subscriber.onNext(new CommonResponse());
                subscriber.onCompleted();
            }
        }).compose(RxSchedulers.<CommonResponse>io_main());
    }

    @Override
    public Observable<CommonResponse> addComment(String publishUserId, CommentItem circleItem) {
        return Observable.create(new Observable.OnSubscribe<CommonResponse>() {
            @Override
            public void call(Subscriber<? super CommonResponse> subscriber) {
                subscriber.onNext(new CommonResponse());
                subscriber.onCompleted();
            }
        }).compose(RxSchedulers.<CommonResponse>io_main());
    }

    @Override
    public Observable<CommonResponse> deleteComment(String commentId) {
        return Observable.create(new Observable.OnSubscribe<CommonResponse>() {
            @Override
            public void call(Subscriber<? super CommonResponse> subscriber) {
                subscriber.onNext(new CommonResponse());
                subscriber.onCompleted();
            }
        }).compose(RxSchedulers.<CommonResponse>io_main());
    }
}
